<?php
session_start();
include_once("WebUtilities.php");
require_once("../DAO/UserDAO.php");

class WebSession
{
	public static function GetSession($name)
	{
//		session_start();
		if(isset($_SESSION[$name]))
		{
			return $_SESSION[$name];
		}
		return null;
	}
	
	public static function SetSession($name, $value)
	{
//		session_start();
		session_register($name);
		$_SESSION[$name] = $value;
	}
	
	public static function CurrentUser($return)
	{
//		session_start();
		if(isset($_SESSION["User"]) == true && $_SESSION["User"] != null)
		{
			return $_SESSION["User"];
		}
		else
		{
			$_SESSION["User"] = null;
			WebUtilities::Redirect("SignIn.php?returnURL=" . $return);
		}
	}	
	
	public static function CurrentUserNoReturn()
	{
//		session_start();
		if(isset($_SESSION["User"]) == true && $_SESSION["User"] != null)
		{
			return $_SESSION["User"];
		}
		else
		{
			return null;
		}
	}	
	
	public static function SetCurrentUser($user)
	{
//		session_start();
		session_register("User");
		$_SESSION["User"] = $user;
	}
	
	public static function SignOut()
	{
//		session_start();
		session_destroy();
		WebUtilities::Redirect("index.php");
	}
}

?>